﻿/* 
 * Copyright (c) 2010 Letwory Interactive
 * All rights reserved.
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * -- Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * -- Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * Original contributor: Nathan Letwory
 */

using System;

namespace VerseSharp
{
    public class MaterialFragmentAnimation: IMaterialFragment
    {
        public FragmentType ID { get { return FragmentType.Animation; } }
        private string _label;
        public string Label
        {
            get { return _label; }
            set
            {
                if (value != null)
                {
                    if (value.Length <= 16)
                    {
                        _label = value;
                    }
                    else
                    {
                        _label = value.Substring(0, 16);
                    }
                }
            }
        }

        public void Deserialize(byte[] source, ref int pos)
        {
            _label = Utils.GetString(source, 16, ref pos);
        }

        public void Serialize(byte[] destination, ref int pos)
        {
            Utils.PutString(destination, _label, 16, ref pos);
        }
    }
}
